package my.mall.front.api.config

import com.alipay.api.AlipayClient
import com.alipay.api.DefaultAlipayClient
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
open class AlipayConfig {
    @Value("\${alipay.server-url}")
    private val serverUrl: String? = null

    @Value("\${alipay.app-id}")
    private val appId: String? = null

    @Value("\${alipay.private-key}")
    private val privateKey: String? = null

    @Value("\${alipay.public-key}")
    private val publicKey: String? = null

    @Bean(name = ["alipayClient"])
    open fun alipayClient(): AlipayClient {
        return DefaultAlipayClient(serverUrl, appId, privateKey, "json", "UTF-8", publicKey, "RSA2")
    }
}
